package com.example.trackcircuitdiagnosis.controller;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class test {

    public static void main(String[] args) {
        Lock lock = new ReentrantLock();
        new Thread(() -> {
            if (lock.tryLock()) {
                try {
                    System.out.println("A");
                } finally {
                    lock.unlock();
                }
            }
        }).start();
        new Thread(() -> {
            if (lock.tryLock()) {
                try {
                    System.out.println("B");
                } finally {
                    lock.unlock();
                }
            }
        }).start();
        new Thread(() -> {
            while (lock.tryLock()) {
                try {
                    System.out.println("C");
                } finally {
                   lock.unlock();
                }
            }        }).start();
    }
}
